<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>云打印机基础系统代码架构演示</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', 'Arial', sans-serif;
            background: linear-gradient(135deg, #1e3c72, #2a5298);
            color: #333;
            overflow-x: auto;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        .header {
            text-align: center;
            color: white;
            margin-bottom: 30px;
        }

        .header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }

        .header p {
            font-size: 1.2em;
            opacity: 0.9;
        }

        .tabs {
            display: flex;
            background: rgba(255,255,255,0.1);
            border-radius: 10px 10px 0 0;
            overflow: hidden;
            margin-bottom: 0;
        }

        .tab {
            flex: 1;
            padding: 15px 20px;
            background: rgba(255,255,255,0.1);
            color: white;
            cursor: pointer;
            text-align: center;
            transition: all 0.3s ease;
            border: none;
            font-size: 16px;
        }

        .tab:hover {
            background: rgba(255,255,255,0.2);
        }

        .tab.active {
            background: white;
            color: #1e3c72;
            font-weight: bold;
        }

        .content {
            background: white;
            border-radius: 0 0 15px 15px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }

        .architecture-map {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            justify-content: center;
            margin-bottom: 30px;
        }

        .module {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 20px;
            border-radius: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            min-width: 200px;
            position: relative;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .module:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 30px rgba(0,0,0,0.2);
        }

        .module.active {
            background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
            transform: scale(1.05);
        }

        .module h3 {
            font-size: 1.3em;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }

        .module .icon {
            margin-right: 10px;
            font-size: 1.5em;
        }

        .module p {
            opacity: 0.9;
            line-height: 1.4;
        }

        .module .file-count {
            position: absolute;
            top: 10px;
            right: 15px;
            background: rgba(255,255,255,0.2);
            border-radius: 50%;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8em;
            font-weight: bold;
        }

        .file-detail {
            background: #f8f9fa;
            border-left: 4px solid #007bff;
            padding: 20px;
            margin: 20px 0;
            border-radius: 0 10px 10px 0;
            position: relative;
            overflow: hidden;
        }

        .file-detail::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient(90deg, #007bff, #00d4ff);
        }

        .file-detail h4 {
            color: #007bff;
            font-size: 1.4em;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
        }

        .file-detail .file-icon {
            margin-right: 10px;
            color: #ffd700;
        }

        .file-detail .file-path {
            background: #e9ecef;
            padding: 5px 10px;
            border-radius: 5px;
            font-family: 'Courier New', monospace;
            font-size: 0.9em;
            color: #495057;
            margin-bottom: 10px;
            display: inline-block;
        }

        .code-preview {
            background: #2d3748;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 10px;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            line-height: 1.6;
            margin: 15px 0;
            position: relative;
            overflow-x: auto;
        }

        .code-preview::before {
            content: 'Python';
            position: absolute;
            top: 10px;
            right: 15px;
            background: #4a5568;
            padding: 2px 8px;
            border-radius: 5px;
            font-size: 10px;
            text-transform: uppercase;
        }

        .function-list {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 15px;
            margin: 20px 0;
        }

        .function-item {
            background: #f1f5f9;
            border-left: 4px solid #10b981;
            padding: 15px;
            border-radius: 0 10px 10px 0;
        }

        .function-item h5 {
            color: #10b981;
            margin-bottom: 5px;
            font-size: 1.1em;
        }

        .function-item p {
            font-size: 0.9em;
            line-height: 1.4;
            color: #64748b;
        }

        .data-flow {
            margin: 30px 0;
        }

        .flow-step {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            padding: 15px;
            background: linear-gradient(90deg, #e0f2fe, #f3e5f5);
            border-radius: 10px;
            position: relative;
            animation: slideIn 0.6s ease-out;
        }

        .flow-step .step-number {
            background: #2196f3;
            color: white;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 20px;
            font-weight: bold;
            flex-shrink: 0;
        }

        .flow-step .step-content {
            flex: 1;
        }

        .flow-step .step-title {
            font-weight: bold;
            margin-bottom: 5px;
            color: #1565c0;
        }

        .flow-step .step-desc {
            color: #666;
            line-height: 1.4;
        }

        .flow-arrow {
            text-align: center;
            color: #2196f3;
            font-size: 2em;
            margin: 10px 0;
            animation: bounce 2s infinite;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(-20px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {
                transform: translateY(0);
            }
            40% {
                transform: translateY(-10px);
            }
            60% {
                transform: translateY(-5px);
            }
        }

        @keyframes pulse {
            0% {
                box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
            }
            70% {
                box-shadow: 0 0 0 20px rgba(33, 150, 243, 0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
            }
        }

        .active-module {
            animation: pulse 2s infinite;
        }

        .hidden {
            display: none;
        }

        .stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 30px 0;
        }

        .stat-item {
            background: linear-gradient(135deg, #ff9a56, #ff6b95);
            color: white;
            padding: 20px;
            border-radius: 15px;
            text-align: center;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .stat-number {
            font-size: 2.5em;
            font-weight: bold;
            margin-bottom: 10px;
            display: block;
        }

        .loading {
            text-align: center;
            padding: 40px;
        }

        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #3498db;
            border-radius: 50%;
            width: 60px;
            height: 60px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .search-box {
            margin: 20px 0;
            text-align: center;
        }

        .search-box input {
            padding: 12px 20px;
            font-size: 16px;
            border: 2px solid #ddd;
            border-radius: 25px;
            width: 300px;
            max-width: 100%;
            outline: none;
            transition: border-color 0.3s ease;
        }

        .search-box input:focus {
            border-color: #2196f3;
        }

        .highlight {
            background: yellow;
            padding: 2px 4px;
            border-radius: 3px;
        }

        @media (max-width: 768px) {
            .container {
                padding: 10px;
            }
            
            .header h1 {
                font-size: 2em;
            }
            
            .tabs {
                flex-direction: column;
            }
            
            .module {
                min-width: 100%;
            }
            
            .search-box input {
                width: 250px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🖨️ 云打印机基础系统代码架构</h1>
            <p>深度解析 Python BLE GATT 服务器的完整实现</p>
        </div>

        <div class="tabs">
            <button class="tab active" onclick="showTab('overview')">🏗️ 架构总览</button>
            <button class="tab" onclick="showTab('modules')">📦 模块详解</button>
            <button class="tab" onclick="showTab('dataflow')">🔄 数据流程</button>
            <button class="tab" onclick="showTab('stats')">📊 代码统计</button>
        </div>

        <div class="content">
            <!-- 架构总览 -->
            <div id="overview" class="tab-content">
                <h2>🎯 项目架构总览</h2>
                <div class="search-box">
                    <input type="text" id="searchInput" placeholder="搜索模块或功能..." onkeyup="searchModules()">
                </div>
                
                <div class="architecture-map" id="moduleMap">
                    <!-- 动态生成模块 -->
                </div>

                <div id="moduleDetail" class="file-detail hidden">
                    <!-- 模块详情动态加载 -->
                </div>
            </div>

            <!-- 模块详解 -->
            <div id="modules" class="tab-content hidden">
                <h2>📦 核心模块深度解析</h2>
                <div id="moduleAnalysis">
                    <!-- 详细模块分析 -->
                </div>
            </div>

            <!-- 数据流程 -->
            <div id="dataflow" class="tab-content hidden">
                <h2>🔄 系统数据流程演示</h2>
                <div class="data-flow">
                    <div class="flow-step">
                        <div class="step-number">1</div>
                        <div class="step-content">
                            <div class="step-title">🔵 微信小程序发起BLE连接</div>
                            <div class="step-desc">用户在微信小程序中扫描并连接到CloudPrinter设备，建立BLE GATT连接</div>
                        </div>
                    </div>
                    
                    <div class="flow-arrow">⬇️</div>
                    
                    <div class="flow-step">
                        <div class="step-number">2</div>
                        <div class="step-content">
                            <div class="step-title">📡 BLE GATT Server接收连接</div>
                            <div class="step-desc">gatt_server.py 处理连接请求，通过 connection.py 管理连接状态和超时</div>
                        </div>
                    </div>
                    
                    <div class="flow-arrow">⬇️</div>
                    
                    <div class="flow-step">
                        <div class="step-number">3</div>
                        <div class="step-content">
                            <div class="step-title">⚡ 协议处理与数据解析</div>
                            <div class="step-desc">protocol.py 解析JSON命令，fragmentation.py 处理大数据分片传输</div>
                        </div>
                    </div>
                    
                    <div class="flow-arrow">⬇️</div>
                    
                    <div class="flow-step">
                        <div class="step-number">4</div>
                        <div class="step-content">
                            <div class="step-title">🌐 WiFi配置与网络管理</div>
                            <div class="step-desc">network/service.py 协调各服务，通过NetworkManager配置WiFi连接</div>
                        </div>
                    </div>
                    
                    <div class="flow-arrow">⬇️</div>
                    
                    <div class="flow-step">
                        <div class="step-number">5</div>
                        <div class="step-content">
                            <div class="step-title">🔄 系统更新与版本管理</div>
                            <div class="step-desc">version_manager.py 管理版本信息，download_manager.py 处理更新下载</div>
                        </div>
                    </div>
                    
                    <div class="flow-arrow">⬇️</div>
                    
                    <div class="flow-step">
                        <div class="step-number">6</div>
                        <div class="step-content">
                            <div class="step-title">✅ 状态反馈与通知</div>
                            <div class="step-desc">notification.py 通过BLE特征向小程序实时推送操作状态和进度</div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 代码统计 -->
            <div id="stats" class="tab-content hidden">
                <h2>📊 代码统计与分析</h2>
                <div class="stats">
                    <div class="stat-item">
                        <span class="stat-number">47</span>
                        <div>Python源文件</div>
                    </div>
                    <div class="stat-item">
                        <span class="stat-number">8</span>
                        <div>核心模块</div>
                    </div>
                    <div class="stat-item">
                        <span class="stat-number">25</span>
                        <div>BLE服务</div>
                    </div>
                    <div class="stat-item">
                        <span class="stat-number">12</span>
                        <div>安全组件</div>
                    </div>
                </div>
                
                <div class="file-detail">
                    <h4>🎯 代码复杂度分析</h4>
                    <div class="function-list">
                        <div class="function-item">
                            <h5>高复杂度模块</h5>
                            <p>gatt_server.py - BLE GATT服务器核心实现，处理多客户端连接和协议管理</p>
                        </div>
                        <div class="function-item">
                            <h5>中等复杂度模块</h5>
                            <p>protocol.py - 数据协议处理，包含分片重组和JSON解析</p>
                        </div>
                        <div class="function-item">
                            <h5>安全关键模块</h5>
                            <p>security/* - 认证、加密和安全传输组件</p>
                        </div>
                        <div class="function-item">
                            <h5>业务逻辑模块</h5>
                            <p>services/* - 版本管理、下载、安装等核心业务功能</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 模块数据定义
        const modules = {
            ble: {
                name: 'BLE通信层',
                icon: '📡',
                description: 'BLE GATT服务器核心，处理蓝牙通信、连接管理和协议处理',
                files: [
                    {
                        name: 'gatt_server.py',
                        path: 'src/ble/gatt_server.py',
                        description: 'BLE GATT服务器主程序，实现DBus接口和广播管理',
                        functions: ['Advertisement', 'BLEGATTServer', 'start_server', 'handle_connection'],
                        lines: 500,
                        complexity: 'high'
                    },
                    {
                        name: 'connection.py',
                        path: 'src/ble/connection.py',
                        description: '连接管理模块，处理BLE连接状态、超时和会话管理',
                        functions: ['ConnectionManager', 'Connection', 'handle_timeout'],
                        lines: 300,
                        complexity: 'medium'
                    },
                    {
                        name: 'protocol.py', 
                        path: 'src/ble/protocol.py',
                        description: '协议处理器，实现JSON命令解析和响应格式化',
                        functions: ['ProtocolHandler', 'FragmentReassembler', 'process_command'],
                        lines: 400,
                        complexity: 'medium'
                    },
                    {
                        name: 'constants.py',
                        path: 'src/ble/constants.py', 
                        description: 'BLE相关常量定义，包含UUID、状态码和配置参数',
                        functions: ['SERVICE_UUID', 'CHAR_*_UUID', 'STATUS_*'],
                        lines: 76,
                        complexity: 'low'
                    }
                ],
                color: '#667eea'
            },
            network: {
                name: '网络服务层',
                icon: '🌐',
                description: '网络连接管理，WiFi配置和状态监控',
                files: [
                    {
                        name: 'service.py',
                        path: 'src/network/service.py',
                        description: '网络服务主协调器，整合BLE和网络管理功能',
                        functions: ['NetworkService', 'initialize', 'start', 'stop'],
                        lines: 250,
                        complexity: 'high'
                    },
                    {
                        name: 'ble_manager.py',
                        path: 'src/network/ble_manager.py',
                        description: 'BLE服务管理器，控制BLE广播的启动和停止',
                        functions: ['BLEServiceManager', 'enable_ble', 'disable_ble'],
                        lines: 200,
                        complexity: 'medium'
                    },
                    {
                        name: 'monitor.py',
                        path: 'src/network/monitor.py',
                        description: '网络状态监控，检测WiFi连接状态和网络健康度',
                        functions: ['NetworkMonitor', 'check_connectivity', 'monitor_changes'],
                        lines: 180,
                        complexity: 'medium'
                    }
                ],
                color: '#f093fb'
            },
            services: {
                name: '核心业务服务',
                icon: '⚙️',
                description: '版本管理、更新下载和安装等核心业务逻辑',
                files: [
                    {
                        name: 'version_manager.py',
                        path: 'src/services/version_manager.py',
                        description: '版本管理系统，处理版本比较、查询和持久化存储',
                        functions: ['VersionManager', 'Version', 'compare_versions', 'update_version'],
                        lines: 350,
                        complexity: 'medium'
                    },
                    {
                        name: 'download_manager.py',
                        path: 'src/services/download_manager.py',
                        description: '更新包下载管理，支持断点续传和校验和验证',
                        functions: ['DownloadManager', 'download_update', 'verify_checksum'],
                        lines: 300,
                        complexity: 'medium'
                    },
                    {
                        name: 'install_manager.py',
                        path: 'src/services/install_manager.py',
                        description: '系统更新安装器，实现原子安装和回滚机制',
                        functions: ['InstallManager', 'atomic_install', 'rollback'],
                        lines: 280,
                        complexity: 'high'
                    }
                ],
                color: '#4facfe'
            },
            security: {
                name: '安全认证模块',
                icon: '🔐',
                description: '设备认证、数据加密和安全传输保护',
                files: [
                    {
                        name: 'auth_manager.py',
                        path: 'src/ble/security/auth_manager.py',
                        description: '认证管理器，处理PIN码验证和会话管理',
                        functions: ['AuthManager', 'authenticate', 'validate_session'],
                        lines: 220,
                        complexity: 'medium'
                    },
                    {
                        name: 'key_manager.py',
                        path: 'src/ble/security/key_manager.py',
                        description: '密钥管理系统，处理加密密钥的生成和存储',
                        functions: ['KeyManager', 'generate_keys', 'store_key'],
                        lines: 180,
                        complexity: 'medium'
                    },
                    {
                        name: 'secure_transport.py',
                        path: 'src/ble/security/secure_transport.py',
                        description: '安全传输层，提供端到端加密通信',
                        functions: ['SecureTransport', 'encrypt_data', 'decrypt_data'],
                        lines: 200,
                        complexity: 'high'
                    }
                ],
                color: '#fa709a'
            },
            diagnostics: {
                name: '智能诊断系统',
                icon: '🔍',
                description: '故障检测、问题分析和智能诊断报告生成',
                files: [
                    {
                        name: 'diagnostic_engine.py',
                        path: 'src/diagnostics/diagnostic_engine.py',
                        description: '诊断引擎核心，协调各种诊断检测器和分析器',
                        functions: ['DiagnosticEngine', 'run_diagnostics', 'analyze_results'],
                        lines: 280,
                        complexity: 'high'
                    },
                    {
                        name: 'problem_detectors.py',
                        path: 'src/diagnostics/problem_detectors.py',
                        description: '问题检测器集合，实现各种硬件和软件问题检测',
                        functions: ['NetworkDetector', 'BluetoothDetector', 'SystemDetector'],
                        lines: 350,
                        complexity: 'medium'
                    }
                ],
                color: '#43e97b'
            },
            config: {
                name: '配置管理模块',
                icon: '📋',
                description: '批量配置、模板管理和离线配置支持',
                files: [
                    {
                        name: 'batch_manager.py',
                        path: 'src/config/batch_manager.py',
                        description: '批量配置管理器，支持多设备统一配置',
                        functions: ['BatchManager', 'apply_batch_config', 'validate_config'],
                        lines: 220,
                        complexity: 'medium'
                    },
                    {
                        name: 'template_manager.py',
                        path: 'src/config/template_manager.py',
                        description: '配置模板管理，支持模板创建、存储和应用',
                        functions: ['TemplateManager', 'create_template', 'apply_template'],
                        lines: 190,
                        complexity: 'medium'
                    }
                ],
                color: '#38ef7d'
            },
            utils: {
                name: '工具组件',
                icon: '🛠️',
                description: 'DBus辅助工具和通用工具函数',
                files: [
                    {
                        name: 'dbus_helper.py',
                        path: 'src/utils/dbus_helper.py',
                        description: 'DBus操作辅助工具，简化DBus接口调用',
                        functions: ['DBusHelper', 'get_adapter', 'get_device_mac'],
                        lines: 150,
                        complexity: 'low'
                    }
                ],
                color: '#667eea'
            }
        };

        // 初始化页面
        function initPage() {
            generateModuleMap();
            generateModuleAnalysis();
        }

        // 生成模块地图
        function generateModuleMap() {
            const moduleMap = document.getElementById('moduleMap');
            moduleMap.innerHTML = '';

            Object.keys(modules).forEach(key => {
                const module = modules[key];
                const moduleElement = document.createElement('div');
                moduleElement.className = 'module';
                moduleElement.style.background = `linear-gradient(135deg, ${module.color}, ${adjustColor(module.color, -20)})`;
                moduleElement.onclick = () => showModuleDetail(key);
                
                moduleElement.innerHTML = `
                    <div class="file-count">${module.files.length}</div>
                    <h3><span class="icon">${module.icon}</span>${module.name}</h3>
                    <p>${module.description}</p>
                `;
                
                moduleMap.appendChild(moduleElement);
            });
        }

        // 显示模块详情
        function showModuleDetail(moduleKey) {
            // 清除所有活动状态
            document.querySelectorAll('.module').forEach(m => m.classList.remove('active'));
            
            // 设置当前模块为活动状态
            event.currentTarget.classList.add('active');
            
            const module = modules[moduleKey];
            const detailDiv = document.getElementById('moduleDetail');
            
            let filesHtml = '';
            module.files.forEach(file => {
                const complexityColor = {
                    'low': '#10b981',
                    'medium': '#f59e0b', 
                    'high': '#ef4444'
                }[file.complexity];

                filesHtml += `
                    <div class="file-detail">
                        <h4><span class="file-icon">📄</span>${file.name}</h4>
                        <div class="file-path">${file.path}</div>
                        <p><strong>功能描述：</strong>${file.description}</p>
                        <p><strong>复杂度：</strong><span style="color: ${complexityColor}; font-weight: bold;">${file.complexity.toUpperCase()}</span> | <strong>代码行数：</strong>${file.lines}</p>
                        
                        <div class="code-preview">
# 核心函数列表
${file.functions.map(func => `def ${func}():`).join('\n')}
                        </div>
                        
                        <div class="function-list">
                            ${file.functions.map(func => `
                                <div class="function-item">
                                    <h5>${func}</h5>
                                    <p>核心功能函数，处理${file.name}中的特定业务逻辑</p>
                                </div>
                            `).join('')}
                        </div>
                    </div>
                `;
            });
            
            detailDiv.innerHTML = `
                <h4><span class="icon" style="font-size: 1.5em;">${module.icon}</span>${module.name} - 详细文件列表</h4>
                ${filesHtml}
            `;
            
            detailDiv.classList.remove('hidden');
            
            // 滚动到详情区域
            detailDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }

        // 生成模块分析
        function generateModuleAnalysis() {
            const analysisDiv = document.getElementById('moduleAnalysis');
            let html = '';
            
            Object.keys(modules).forEach(key => {
                const module = modules[key];
                html += `
                    <div class="file-detail">
                        <h4>${module.icon} ${module.name}</h4>
                        <p><strong>模块职责：</strong>${module.description}</p>
                        <p><strong>文件数量：</strong>${module.files.length} 个</p>
                        <p><strong>代码总行数：</strong>${module.files.reduce((sum, file) => sum + file.lines, 0)} 行</p>
                        
                        <div class="function-list">
                            ${module.files.map(file => `
                                <div class="function-item">
                                    <h5>📄 ${file.name}</h5>
                                    <p>${file.description}</p>
                                    <p><strong>核心函数：</strong>${file.functions.join(', ')}</p>
                                </div>
                            `).join('')}
                        </div>
                    </div>
                `;
            });
            
            analysisDiv.innerHTML = html;
        }

        // 显示标签页
        function showTab(tabName) {
            // 隐藏所有标签内容
            document.querySelectorAll('.tab-content').forEach(content => {
                content.classList.add('hidden');
            });
            
            // 移除所有活动标签状态
            document.querySelectorAll('.tab').forEach(tab => {
                tab.classList.remove('active');
            });
            
            // 显示选中标签内容
            document.getElementById(tabName).classList.remove('hidden');
            
            // 设置选中标签为活动状态
            event.target.classList.add('active');
        }

        // 搜索模块功能
        function searchModules() {
            const searchTerm = document.getElementById('searchInput').value.toLowerCase();
            const moduleElements = document.querySelectorAll('.module');
            
            moduleElements.forEach(element => {
                const text = element.textContent.toLowerCase();
                if (text.includes(searchTerm)) {
                    element.style.display = 'block';
                    // 高亮搜索结果
                    if (searchTerm) {
                        element.classList.add('active-module');
                    } else {
                        element.classList.remove('active-module');
                    }
                } else {
                    element.style.display = searchTerm ? 'none' : 'block';
                    element.classList.remove('active-module');
                }
            });
        }

        // 颜色调整工具函数
        function adjustColor(color, amount) {
            const usePound = color[0] === '#';
            const col = usePound ? color.slice(1) : color;
            const num = parseInt(col, 16);
            let r = (num >> 16) + amount;
            let g = (num >> 8 & 0x00FF) + amount;
            let b = (num & 0x0000FF) + amount;
            r = r > 255 ? 255 : r < 0 ? 0 : r;
            g = g > 255 ? 255 : g < 0 ? 0 : g;
            b = b > 255 ? 255 : b < 0 ? 0 : b;
            return (usePound ? '#' : '') + (r << 16 | g << 8 | b).toString(16).padStart(6, '0');
        }

        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', initPage);
    </script>
</body>
</html>